<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="d1">
        <input type="text" v-model="num" placeholder="请输入1-100之间的整数">
        <input type="button" value="猜一猜" @click="f()">
        <h3>结果:{{info}}</h3>
    </div>
</body>
<script src="../js/vue.js"></script>
<script>
    /* 随机产生1-100整数 */
    let x = parseInt(Math.random() * 100) + 1;
    let count = 0;
    let v = new Vue({
        el : "div",
        data : {
            info : "",
            num : ""
        },
        methods : {
            f() {
                count++;
                if (v.num > x) {
                    v.info = "猜大了!";
                } else if (v.num < x) {
                    v.info = "猜小了!";
                } else {
                    v.info = "恭喜你第"+count+"次猜对了";
                }
            }
        }
    })
</script>
</html>